<template>
	<el-dialog title="服务调用" :visible.sync="dialogVisible" width="900px" @close="handleClose"
		:close-on-click-modal="false">
		<div slot="title" class="dialog-header-title">
			<i class="el-icon-edit-outline"></i>
			<span>服务调用</span>
		</div>

		<div class="smp-search">
			<el-form :inline="false" label-width="140px" size="mini" ref="form" :model="form" :rules="rules">

				<el-row>
					<el-col :span="24">
						<el-col :span="12" >
							<el-form-item label="服务编码(R):" prop="regCode">
								<el-input v-model="form.regCode" placeholder="服务编码(R)" :disabled="true"></el-input>
							</el-form-item>
						</el-col>
						
						<el-col :span="12">
							<el-form-item label="交易码:" prop="transCode"> 
								<el-input v-model="form.transCode" placeholder="交易码" :disabled="true"></el-input>
							</el-form-item>
						</el-col>

						<el-col :span="12">
							<el-form-item label="交易名称:" prop="transName">
								<el-input v-model="form.transName" placeholder="交易名称" :disabled="true"></el-input>
							</el-form-item>
						</el-col>

						<el-col :span="12">
							<el-form-item label="服务系统:" prop="regSysCode">
								<el-select v-model="form.regSysCode" style="width: 100%" filterable remote reserve-keyword
									placeholder="请输入系统编号或名称" :remote-method="getsystems"   :disabled="true">
									<el-option v-for="item in systemListAll" :key="item.systemNo" :label="item.systemName"
										:value="item.systemNo">
										{{ item.systemName }}({{item.systemNo}})
										<!-- <span style="float: left;margin-left: 3px;">{{ item.systemNo }}</span>
										<span style="float: right;margin-right: 3px;">{{ item.systemName }}</span> -->
									</el-option>
								</el-select>
								
							<!-- 	<el-input v-model="form.regSysCode" placeholder="服务系统" :disabled="true"></el-input> -->
							</el-form-item>
						</el-col>


						<el-col :span="12">
							<el-form-item label="消费系统:" prop="pubSysCode">
								<!-- <el-input v-model="form.pubSysCode" placeholder="消费系统" :disabled="true"></el-input>
							 -->
							<el-select v-model="form.pubSysCode" style="width: 100%" filterable remote reserve-keyword
								placeholder="请输入系统编号或名称" :remote-method="getsystems"   :disabled="true">
								<el-option v-for="item in systemListAll" :key="item.systemNo" :label="item.systemName"
									:value="item.systemNo">
									{{ item.systemName }}({{item.systemNo}})
									<!-- <span style="float: left;margin-left: 3px;">{{ item.systemNo }}</span>
									<span style="float: right;margin-right: 3px;">{{ item.systemName }}</span> -->
								</el-option>
							</el-select>
							
							</el-form-item>
						</el-col>
						
						<el-col :span="12">
							<el-form-item label="消费方报文格式:" prop="msgAgreement">
								<el-input v-model="form.msgAgreement" placeholder="消费方报文格式"></el-input>
							</el-form-item>
						</el-col>
						
						
						<el-col :span="12">
							<el-form-item label="消费方字符编码:" prop="msgCode">
								<!-- <el-input v-model="form.msgCode" placeholder="消费方字符编码"></el-input> -->
								<el-select v-model="form.msgCode" style="width: 100%" placeholder="消费方字符编码">
									<el-option v-for="item in dict('SMP0004')" :key="item.itemCode" :label="item.itemName"
										:value="item.itemCode">
									</el-option>
								</el-select>
							</el-form-item>
						</el-col>
						
						
					</el-col>
				</el-row>


			</el-form>
		</div>
		<span slot="footer" class="dialog-footer">
			<el-button size="mini" type="primary" @click="onSubmit">确认</el-button>
			<!-- <el-button size="mini" @click="reset">清空</el-button> -->
			<el-button size="mini" @click="closeDialog">取消</el-button>
		</span>
	</el-dialog>
</template>

<script>
	"use strict";
	export default {
		data() {
			return {
				index:0,
				type:'add',
				dialogVisible: false,
				rules: {
					msgAgreement: [{
						required: true,
						message: "报文格式不能为空",
						trigger: ['blur', 'change']
					}],
					msgCode: [{
						required: true,
						message: "服务编码不能为空",
						trigger: ['blur', 'change']
					}],
					
				},
				form: {
					 regCode: '',
					 transCode: '',
					 transName: '',
					 regSysCode: '',
					 pubSysCode: '',
					 msgAgreement: '',
					 msgCode: ''
				},

			};
		},



		methods: {

			onSubmit() {
				this.dialogVisible = false;
				let data = {};
				Object.assign(data,this.form);
				if(this.type=='add'){
					this.$emit('addApplySystemCall',data);
				}else{
					this.$emit('updateApplySystemCall',data,this.index);
				}
				
				this.$refs["form"].resetFields();
			
			},

			reset() {
				this.$refs["form"].resetFields();
			},

			// systemRegister() {
			// 	this.$refs["form"].validate(valid => {
			// 		if (valid) {
			// 			addSystemInfo(this.form).then(response => {
			// 				this.data = response.data.extend;
			// 				this.$message({
						//duration:5000,
			// 					type: 'success',
			// 					message: '系统登记成功！'
			// 				});
			// 				this.form = {};
			// 				this.$refs["form"].resetFields();
			// 				this.dialogVisible = false;
			// 				this.$emit("onSubmit");
			// 			}).catch(error => {
			// 				this.$message({
						//duration:5000,			// 					type: 'error',
			// 					message: '系统登记失败！'
			// 				});
			// 				this.form = {};
			// 				this.$refs["form"].resetFields();
			// 				this.dialogVisible = false;
			// 				this.$emit("onSubmit");
			// 			});
			// 		}
			// 	})

			// },

			showDialog() {
				this.type='add';
				this.dialogVisible = true;
			},
			
			showDialog2(row,index) {
				this.type='update';
				this.index = index;
				this.form = row;
				this.dialogVisible = true;
			
			},
			
			closeDialog() {
				this.$refs["form"].resetFields();
				this.dialogVisible = false;
			},

			handleClose() {
				this.dialogVisible = false;
			}


		},

	}
</script>

<style>
</style>
